package com.letv.whatslive.model.convert;

import com.letv.whatslive.common.utils.ObjectUtils;
import com.letv.whatslive.model.Bank;
import com.letv.whatslive.model.utils.ObjUtils;
import com.mongodb.BasicDBObject;
import com.mongodb.DBObject;

/**
 * Created by Administrator on 2016/2/22.
 */
public class BankConvert {
    public static DBObject castBankToDBObject(Bank bank) {
        DBObject dbo = new BasicDBObject();
        if (bank.getId() != null) {
            dbo.put("_id", bank.getId());
        }
        dbo.put("bankName", ObjUtils.ifNull(bank.getBankName(), ""));
        return dbo;
    }
    public static Bank castDBObjectToBank(DBObject dbObject){
        if(dbObject!=null){
            Bank bank=new Bank();
            bank.setId(ObjectUtils.toLong(dbObject.get("_id")));
            bank.setBankName(ObjectUtils.toString(dbObject.get("bankName")));
            return bank;
        }else{
            return null;
        }
    }
}
